package com.rich.broker.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rich.broker.mapper.BrokerMapper;
import com.rich.broker.service.BrokerService;
import com.rich.broker.vo.BrokerVo;
import com.rich.common.entity.TbBroker;
import com.rich.common.result.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author HanSama
 * @date 2021年08月16日 18:49
 */
@Service
public class BrokerServiceImpl implements BrokerService {

    @Autowired
    private BrokerMapper brokerMapper;

    /**
     * 获取个人详情
     * @author HanSama
     * @date 2021/8/16 19:26
     * @param id
     * @return com.rich.common.entity.TbBroker
     */
    @Override
    public TbBroker findOneById(Long id) {
        return brokerMapper.findOneById(id);
    }

    /**
     * 获取排行榜
     * @author HanSama
     * @date 2021/8/16 19:26
     * @param brokerName
     * @return java.util.List<com.rich.common.entity.TbBroker>
     */
    @Override
    public List<TbBroker> rankingList(String brokerName) {

        return brokerMapper.rankingList(brokerName);
    }

    @Override
    public ResultData brokerList(BrokerVo brokerVo) {
        PageHelper.startPage(brokerVo.getPage(), brokerVo.getLimit());
        List<TbBroker> list = brokerMapper.brokerList(brokerVo);
        PageInfo pageInfo = new PageInfo(list);
        return new ResultData(pageInfo.getList(),pageInfo.getTotal());
    }

    @Override
    public void delBoker(Integer id) {
        brokerMapper.delBoker(id);
    }

    @Override
    public void updStatus(Integer id, String status) {
        brokerMapper.updStatus(id,status);
    }

    @Override
    public void updBroker(TbBroker tbBroker) {
        brokerMapper.updBroker(tbBroker);
    }

    @Override
    public void addBroker(TbBroker tbBroker) {
        brokerMapper.addBroker(tbBroker);
    }
}
